package org.zh.sh.sv;

import org.zh.sh.entity.Teacher;
import org.zh.sh.util.jdbc.ZHOpenJdbcUtil;
import org.zh.sh.util.proxy.Service;
import org.zh.sh.util.jdbc.Transaction;

import java.util.Map;

import static org.zh.sh.util.Utils.removeEmpty;

@Service
public class TeacherSV extends Teacher {

    @Transaction
    public Map<String, Object> insert(Map<String, Object> teacher)  {
        return ZHOpenJdbcUtil.insertPri(tableName,removeEmpty(teacher));
    }

    @Transaction
    public void insertVoid(Map<String, Object> teacher) {
         ZHOpenJdbcUtil.insertVoid(tableName,removeEmpty(teacher));
    }
    @Transaction
    public int updateById(Map<String, Object> teacher)  {
      return  ZHOpenJdbcUtil.executeUpdate(updateAll,teacher.get(teacherAddress),teacher.get(teacherAge),teacher.get(teacherBirthday),teacher.get(teacherEducationalBackground),teacher.get(teacherEmail),teacher.get(teacherEthnicGroup),teacher.get(teacherGender),teacher.get(teacherHobbies),teacher.get(teacherIdentityCard),teacher.get(teacherName),teacher.get(teacherNationality),teacher.get(teacherOnboardingDate),teacher.get(teacherPhoneNumber),teacher.get(teacherSalary),teacher.get(teacherSchool),teacher.get(teacherSpecialty),teacher.get(teacherTeachingCertificate),teacher.get(teacherId));
    }

    @Transaction(readOnly = true)
    public Map<String, Object> queryById(Long id) {
        return  ZHOpenJdbcUtil.executeQueryOne(queryById,id);
    }

    @Transaction
    public int deleteById(Long id)  {
        return  ZHOpenJdbcUtil.executeUpdate(deleteById,id);
    }

}
